﻿using Autofac;
using DBContext;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoneLine.Models;
using ZoneLine.Models.PackageModel;

namespace ZoneLine.ViewModels
{
    public class InitHelper
    {
        public static void DeleteTodayDatas()
        {
            var dal = ContainerServer.Container.Resolve<IModelDAL>();

            dal.DeleteModel<AbsPrintResult>(p => p.PrintTime < DateTime.Now.Date.AddDays(1) && p.PrintTime > DateTime.Now.Date);

            dal.DeleteModel<HOP010StationResult>(p => p.CreateTime < DateTime.Now.Date.AddDays(1) && p.CreateTime > DateTime.Now.Date);
            dal.DeleteModel<HOP040StationResult>(p => p.CreateTime < DateTime.Now.Date.AddDays(1) && p.CreateTime > DateTime.Now.Date);

            dal.DeleteModel<PackageResult>(p => p.PackageTime < DateTime.Now.Date.AddDays(1) && p.PackageTime > DateTime.Now.Date);
            dal.DeleteModel<PackageResult>(p => p.PrintTime < DateTime.Now.Date.AddDays(1) && p.PrintTime > DateTime.Now.Date);

            dal.DeleteModel<PackageTempModel>(p => p.PrintTime < DateTime.Now.Date.AddDays(1) && p.PrintTime > DateTime.Now.Date);
            dal.DeleteModel<PackageTempModel>(p => p.PackageTime < DateTime.Now.Date.AddDays(1) && p.PackageTime > DateTime.Now.Date);

            var dt = DateTime.Now;
            var days = (dt - DateTime.Parse("2020-01-01")).Days;
            dal.DeleteModel<PieceIndexModel>(p => p.DayIndex > days - 1);

            dal.DeleteModel<QOP006StationResult>(p => p.CreateTime < DateTime.Now.Date.AddDays(1) && p.CreateTime > DateTime.Now.Date);
            dal.DeleteModel<QOP010StationResult>(p => p.CreateTime < DateTime.Now.Date.AddDays(1) && p.CreateTime > DateTime.Now.Date);
            dal.DeleteModel<QOP020StationResult>(p => p.CreateTime < DateTime.Now.Date.AddDays(1) && p.CreateTime > DateTime.Now.Date);
            dal.DeleteModel<QOP050LStationResult>(p => p.CreateTime < DateTime.Now.Date.AddDays(1) && p.CreateTime > DateTime.Now.Date);
            dal.DeleteModel<QOP050RStationResult>(p => p.CreateTime < DateTime.Now.Date.AddDays(1) && p.CreateTime > DateTime.Now.Date);


        }
    }
}
